package com.bigData.main.mapper;

import com.bigData.main.pojo.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper     //标注此接口为数据库访问层
public interface UserMapper {

    //调用方法自动执行sql
    @Insert("insert into user_info(uname ,upass,uroot) values (#{uname},#{upass},1)")
    Integer insertUser(UserInfo u);

    @Delete("delete from user_info where uname=#{uname}")
    Integer deleteUser(UserInfo u);

    @Update("UPDATE user_info SET uname = #{uname} WHERE uid = #{uid} ")
    Integer updateUsername(UserInfo u);

    @Update("update  user_info set upass = (#{upass}) where uid=#{uid} or uname = (#{uname})")
    Integer updateUserPass(UserInfo u);

    @Update("update  user_info set uroot = (#{uroot}) where uname=#{uname}")
    Integer updateURoot(UserInfo u);

    @Select("select * from user_info ")
    List<UserInfo> selectUser();

    //登录逻辑---根据用户名查密码
    @Select("select * from user_info where uname=#{uname}")
    UserInfo getUserPass(UserInfo u);

    @Select("select upass from user_info where uname=#{uname}")
    UserInfo getUserName(UserInfo u);
}

